home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / ansi / math / elefunt / ran.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-28  |  711 b   |  25 lines

  1. /* -*-C-*- ran.c */
  2.  
  3. #include "elefunt.h"
  4.  
  5. /***********************************************************************
  6. Random number generator - based on Algorithm 266 by Pike and Hill
  7. (modified by Hansson), Communications of the ACM, Vol. 8, No. 10,
  8. October 1965.
  9.  
  10. This subprogram is intended for use on computers with fixed point
  11. wordlength of at least 29 bits.  It is best if the floating point
  12. significand has at most 29 bits.
  13. ***********************************************************************/
  14.  
  15. float
  16. ran(k)
  17. int k;                    /* unused argument */
  18. {
  19.     static long iy = 100001L;
  20.  
  21.     iy = iy * 125;
  22.     iy = iy - (iy / 2796203L) * 2796203L;
  23.     return (((float) (iy)) / 2796203.0e0);
  24. }
  25.